/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */

/**
 * 最简单的 form writer
 * 使用该 Writer 时应该 设置 Proxy#batchActions = false
 * 否则 Proxy 会将多个更新合并为一个请求
 * TODO 等待服务器端容易处理批量json create update 时直接换用 废弃该类
 *
 * @author Vacoor
 */
Ext.define('Ext.data.writer.Form', {
    extend: 'Ext.data.writer.Writer',
    alternateClassName: 'Ext.data.FormWriter',
    alias: 'writer.form',

    //inherit docs
    writeRecords: function (request, data) {
        if (data.length !== 1) {
            Ext.Error.raise('Data must be decode single record when using this writer, You must be disabled Proxy batchActions.');
        }
        request.params = data[0];
        return request;
    }
});
